package com.sto.stoapp.listener;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.log.ExceptionLog;
import com.sto.stoapp.widget.BaseDialog;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;

/**
 * 抽象长按事件
 * 
 * @author mgf
 * 
 */
public abstract class StoOnItemLongClickListener implements
		OnItemLongClickListener {

	private Activity activity;

	/**
	 * 构造函数
	 * 
	 * @param activity
	 */
	public StoOnItemLongClickListener(Activity activity) {
		this.activity = activity;
	}

	@Override
	public boolean onItemLongClick(AdapterView<?> parent, View view,
			int position, long id) {
		try {
			KcOnItemLongClickListener(parent, view, position, id);
		} catch (Exception e) {
			final BaseDialog dialog = new BaseDialog(activity);
			dialog.setTitles(activity.getText(R.string.confirm).toString());
			dialog.getvCanncel().setVisibility(View.GONE);
			dialog.setOnBackClickListener(new OnBackClickListener() {

				@Override
				public void onBackClickListener(boolean res) {
					dialog.dismiss();
				}
			});
			ExceptionLog.writeLog("StoOnItemLongClickListener", e.getMessage());
		}
		return false;
	}

	/**
	 * 
	 * @param parent
	 * @param view
	 * @param position
	 * @param id
	 */
	public abstract boolean KcOnItemLongClickListener(AdapterView<?> parent,
			View view, int position, long id);
}
